package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import one.stand.aop.ApiController;
import one.stand.exception.ParamException;
import one.stand.model.ResultModel;
import one.stand.request.BaseRequest;
import one.stand.request.BusinessCardRequest;
import one.stand.request.essay.*;
import one.stand.response.BusinessCardResponse;
import one.stand.response.essay.*;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author luoyang
 * @date 2020/5/13 14:14
 */
@RestController
@RequestMapping("crmPc/customerEssay")
@Api(description = "获客文章管理",tags="获客文章管理")
@Slf4j
public class CustomerEssayController  extends BaseController {
    /**
     * 员工数据查询
     * @param request
     * @return
     */
    @PostMapping("queryStaffData")
    @ApiOperation(value = "员工数据查询")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayStaffDataRequest.class)
    public ResultModel queryStaffData(@RequestAttribute EssayStaffDataRequest request){
        return crmFegin.queryStaffData(request);
    }

    /**
     * 添加或更新获客文章员工数据
     * @param request
     * @return
     */
    @PostMapping("addStaffData")
    @ApiOperation(value = "添加或更新获客文章员工数据")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayStaffDataFrom.class)
    public ResultModel<Boolean> addStaffData(@RequestAttribute EssayStaffDataFrom request){
        return crmFegin.addStaffData(request);
    }

    /**
     * 添加或更新访客数据
     * @param request
     * @return
     */
    @PostMapping("addVisitorsData")
    @ApiOperation(value = "添加或更新访客数据")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayVisitorsDataForm.class)
    public ResultModel<Boolean> addVisitorsData(@RequestAttribute EssayVisitorsDataForm request) throws ParamException {
        return crmFegin.addVisitorsData(request);
    }


    /**
     * 添加或更新员工分享数据
     * @param request
     * @return
     */
    @PostMapping("addShareRecordData")
    @ApiOperation(value = "添加或更新员工分享数据")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayRecordForm.class)
    public ResultModel<Boolean> addShareRecordData(@RequestAttribute EssayRecordForm request) throws ParamException {
        return crmFegin.addShareRecordData(request);
    }

    /**
     * 员工分享详情
     * @param request
     * @return
     */
    @PostMapping("queryStaffShareDetail")
    @ApiOperation(value = "员工分享详情")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayShareDetailRequest.class)
    public ResultModel<List<EssayShareDetailResponse>> queryStaffShareDetail(@RequestAttribute EssayShareDetailRequest request){
        return crmFegin.queryStaffShareDetail(request);
    }


    /**
     * 访客数据查询
     * @param request
     * @return
     */
    @PostMapping("queryVisitorsData")
    @ApiOperation(value = "访客数据查询")
    @ApiController(isLogin = true,company = true,card = true,paramClass = EssayVisitorsDataRequest.class)
    public ResultModel<List<EssayVisitorsDataResponse>> queryVisitorsData(@RequestAttribute EssayVisitorsDataRequest request){
        return crmFegin.queryVisitorsData(request);
    }


    /**
     * 查询公司员工
     * @param request
     * @return
     * @throws ParamException
     */
    @PostMapping("queryCompanyStaff")
    @ApiController(isLogin = true,company = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> queryCompanyStaff(@RequestAttribute BusinessCardRequest request){
        return crmFegin.queryCompanyStaff(request);
    }


    /**
     * 转载文章解析
     * @param request
     * @return
     * @throws ParamException
     */
    @PostMapping("reprintArticle")
    @ApiController(isLogin = true,company = true,card = true,paramClass = ReprintArticleForm.class)
    public ResultModel<ReprintArticleResponse> reprintArticle(@RequestAttribute ReprintArticleForm request){
        return crmFegin.reprintArticle(request);
    }
}
